package com.chorye.datasource.controller;

import com.chorye.datasource.entity.Student;
import com.chorye.datasource.entity.StudentThird;
import com.chorye.datasource.service.StudentService;
import com.chorye.datasource.service.StudentThirdService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @Company: 北京XXXX有限公司
 * @Author JiangYy
 * @Title: TestController
 * @Description: TODO
 * @Date 2018/12/13 9:21
 */

@RestController
@RequestMapping("/test")
@Slf4j
public class TestController {

    @Autowired
    private StudentService studentService;
    @Autowired
    private StudentThirdService studentThirdService;

    @GetMapping("/dataSource")
    public void testDataSource() {
        Student student = new Student();
        student.setName("测试思密达");
        student.setAge(11);
        student.setMobile("13512323333");
        student.setAddress("五棵松");
        student.setSalary(new BigDecimal(999));
        int studentCount = studentService.insert(student);
        log.info("普通库插入成功数量" + studentCount);

//        int i = 1 / 0;

        StudentThird studentThird = new StudentThird();
        studentThird.setName("测试思密达");
        studentThird.setAge(11);
        studentThird.setMobile("13512323333");
        studentThird.setAddress("五棵松");
        studentThird.setSalary(new BigDecimal(999));
        int studentThirdCount = studentThirdService.insert(studentThird);
        log.info("三方库插入成功数量" + studentThirdCount);
    }
}
